package com.zac.junit;

/**
 * 
 *  Anything : Matches to absolutely anything. Useful in some cases where you want
 *	to make the assert statement more readable.
 * 
 *  is : This matcher is used only to improve the readability of your statements.
 * 
 *  allOf : A matcher that checks if all contained matchers match (just like the && operator).
 * 
 *  anyOf : hecks if any of the contained matchers A matcher that c match (like the operator ||).
 * 
 *  not : A matcher that traverses the meaning of the contained matchers (just 
 *  like the ! operator in Java).
 *  
 *  instanceOf, isCompatibleType : A matchers that matches whether objects are of 
 *  compatible type (are instance of one another).
 *  
 *  sameInstance : A matcher to test object identity.
 *  
 *  notNullValue, nullValue : A matcher to test for null values (or non-null values).
 *  
 *  hasProperty : A matcher to test whether a Java Bean has a certain property.
 *  
 *  hasEntry, hasKey, hasValue : This matcher tests whether a given Map has a 
 *  given entry, key or value.
 *  
 *  hasItem, hasItems : This matchers tests a given collection for presence of item or items.
 *  
 *  closeTo, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual : 
 *  	Test given numbers are close to, greater than, greater than or equal,
 *  less than or less than or equal to a given value.
 *  
 *  equalToIgnoringCase : Tests a given string equals another one, ignoring the case.
 *  
 *  equalToIgnoringWhiteSpace : Tests a given string equals another one, by 
 *  ignoring the white spaces.
 *  
 *  containsString, endsWith, startWith : Tests whether the given string contains, 
 *  starts with or ends with a certain string.
 */

import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

/**
 * @author ZacTse
 *
 */
public class HamcrestTest {

	private List<String> values;

	@Before
	public void setUpList() {
		values = new ArrayList<String>();
		values.add("x");
		values.add("y");
		values.add("z");

	}

	@Test
	public void withoutHamcrest() {
		assertTrue(values.contains("one") || values.contains("two")
				|| values.contains("three"));

	}
	
	@SuppressWarnings("unchecked")
	@Test
	public void withHamcrest() {
		assertThat(values, hasItem(allOf(equalTo("one"), equalTo("two"),
				equalTo("three"))));
		
	}
	
}
